<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>


<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${applicationScope.KEY_SITE_NAME}</title>
<link href="resources/css/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="resources/css/ichecker/square/blue.css" rel="stylesheet" type="text/css" />
<link href="resources/css/intstyle.css" rel="stylesheet" type="text/css" />
<link href="resources/css/combobox.css" rel="stylesheet" type="text/css" />
<link href="resources/css/timepicker/jquery-ui-timepicker-addon.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="resources/scripts/jquery-1.9.1.js"></script>
<script type="text/javascript" src="resources/scripts/jquery-ui.custom.js"></script>
<script type="text/javascript" src="resources/scripts/jquery.blockUI.js"></script>
<script type="text/javascript" src="resources/scripts/jquery.icheck.js"></script>
<script type="text/javascript" src="resources/scripts/common.js"></script>
<script type="text/javascript" src="resources/scripts/jquery.validate.js"></script>
<script type="text/javascript" src="resources/scripts/combobox.js"></script>
<script type="text/javascript" src="resources/scripts/timepicker/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="resources/scripts/timepicker/i18n/jquery-ui-timepicker-ja.js"></script>
<script type="text/javascript" src="resources/rater/js/jquery.raty.min.js"></script>
<script type="text/javascript" src="resources/scripts/fileupload.js"></script>
<script type="text/javascript" src="resources/scripts/jquery.form.js"></script>

<script type="text/javascript">
<!--
	$(document)
			.ready(
					function() {

						
						renderButtons();
						changeSideMenuBackColor("sideMenuGameAdd");
						renderCheckBox();
						
						$( "#typeId" ).combobox();
						$('#startDt').datetimepicker({dateFormat: "yy-mm-dd"});
						raty("popuRater","popularity","${game.popularity}");
						raty("feaRater","feasibility", "${game.feasibility}");
						
						
						$("#form").validate({
					        rules: {
					   name: {
						   required:true,
						   maxlength:40
					   },
					   keywords: {
						   required:true,
						   maxlength:40
					   },
					   company:  {
						   maxlength:40
					   },
					   url: {
						   maxlength:100  
					   },
					   downloadMethod: {
						   maxlength:150
					   }
					  },
					   messages: {
					   name: {
						  required:"<spring:message code="msg.input.field.required"/>",
						  maxlength:jQuery.format("<spring:message code="msg.input.field.maxlength"/>")
					   },
					   keywords: {
						   required:"<spring:message code="msg.input.field.required"/>",
						   maxlength:jQuery.format("<spring:message code="msg.input.field.maxlength"/>")
					   },
					   company: {
						   maxlength:jQuery.format("<spring:message code="msg.input.field.maxlength"/>")
					   },
					   url: {
						   maxlength:jQuery.format("<spring:message code="msg.input.field.maxlength"/>")   
					   },
					   downloadMethod: {
						   maxlength:jQuery.format("<spring:message code="msg.input.field.maxlength"/>")    
					   }
					  },
					    
					  submitHandler:function(form){
						  updateGame();
					  }
					 
					 });

	});

	function updateGame() {

		getBlockUI();		
		$.post( "admin/game/update",			
				$("#form").serialize(),			
				function(obj, html) {
					$.unblockUI();
					if (obj.accessDenied) {
						showInfoDialog("error",data.message);	
					} else {
						window.location="<%=basePath%>admin/game/list";
					}
				}
		);
	}
//-->
</script>

<!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* 此 1px 负边距可以放置在此布局中的任何列中，且具有相同的校正效果。 */
ul.nav a { zoom: 1; }  /* 缩放属性将为 IE 提供其需要的 hasLayout 触发器，用于校正链接之间的额外空白 */
</style>
<![endif]-->
</head>

<body>

	<div class="container">
		<%@include file="../../header.jsp"%>
		<%@include file="../sidebar.jsp"%>
		<div id="contentBoxDiv" class="content">
			<div class="subnav">
				<spring:message code="Label.menu.headnav.goods" />
				&gt;&gt;
				<spring:message code="Label.menu.game.main" />
				&gt;&gt;
				<spring:message code="Label.game.editgame" />
			</div>
			<%@include file="../../errorMessagePanel.jsp"%>
			<div class="box">
				<h2>
						<spring:message code="Label.game.editgame" />
				</h2>

				<div class="box" style="border: none;">

					<form id="form" name="form" method="post" enctype="multipart/form-data">

						<fieldset>
							<div class="formfield">

								<div class="formLabel">
									<label for="typeId"><spring:message	code="Label.game.type" /></label>
								</div>
								<div class="forminput">
									<select id="typeId" name="typeId">
									<c:forEach items="${gameTypes}" var="type">
										<option value="${type.typeId}" <c:if test="${type.typeId == game.typeId}"> selected="selected" </c:if>>${type.typeName}</option>
									</c:forEach>
									</select>
								</div>

							</div>

							<div class="formfield">

								<div class="formLabel">
									<label for="name"><spring:message code="Label.game.name"/></label>
								</div>
								<div class="forminput">
									<input type="text" id="name" name="name" class="text ui-widget-content ui-corner-all" value="${game.name}"/>
									<input type="hidden" id="gameId" name="gameId" value="${game.gameId}"/>
									<input type="hidden" id="status" name="status" value="${game.status}"/>
								</div>

							</div>

							<div class="formfield">

								<div class="formLabel">
									<label for="keywords"><spring:message code="Label.game.keywords"/><spring:message code="Label.game.keywords.notice"/></label>
								</div>
								<div class="forminput">
									<input type="text" id="keywords" name="keywords" class="text ui-widget-content ui-corner-all" value="${game.keywords}"/>
								</div>

							</div>

							<div class="formfield">

								<div class="formLabel">
									<label for="company"><spring:message code="Label.game.org"/></label>
								</div>
								<div class="forminput">
									<input type="text" id="company" name="company"	class="text ui-widget-content ui-corner-all" value="${game.company}"/>
								</div>

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="url"><spring:message code="Label.game.url"/></label>
								</div>
								<div class="forminput">
									<input type="text" id="url" name="url" class="text ui-widget-content ui-corner-all" value="${game.url}"/>
								</div>

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="downloadMethod"><spring:message code="Label.game.download"/></label>
								</div>
								<div class="forminput">
									<input type="text" id="downloadMethod" name="downloadMethod" class="text ui-widget-content ui-corner-all" value="${game.downloadMethod}"/>
								</div>

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="startDt"><spring:message code="Label.game.startDate"/></label>
								</div>
								
								<div class="forminput">
									<input type="text" name="startDt" id="startDt" class="text ui-widget-content ui-corner-all" readonly="readonly" value="${game.startDtStr}"/>
								</div>
								

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="cost"><spring:message code="Label.game.cost"/></label>
								</div>
								<div class="forminput">
									<input type="text" id="cost" name="cost" class="text ui-widget-content ui-corner-all" value="${game.cost}"/>
								</div>

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="produceMethod"><spring:message code="Label.game.produceMethod"/></label>
								</div>
								
								<div class="forminput">
									<input type="text" name="produceMethod" id="produceMethod" class="text ui-widget-content ui-corner-all" value="${game.produceMethod}"/>
								</div>

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="logoUrl"><spring:message code="Label.game.logo"/></label>
								</div>
								<div class="forminput">
									<input type="file" id="inputfile" name="inputfile" class="text ui-widget-content ui-corner-all" />
									<input type="hidden" id="logoUrl" name="logoUrl" value="${game.logoUrl}"/>
									<div id="feedback">
									<c:if test="${not empty game.logoUrl}">
										<img height="80" width="200" src="fileupload/gamelogo/${game.logoUrl}"/>
									</c:if>
									</div>
								</div>
								
							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="popularity"><spring:message code="Label.game.popularity"/></label>
								</div>
								
								<div class="forminput" id="popuRater">
									<input type="hidden" id="popularity" name="popularity" value="${game.popularity}"/>		
								</div>

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="feasibility"><spring:message code="Label.game.feasibility"/></label>
								</div>
								
								<div class="forminput" id="feaRater">
									<input type="hidden" id="feasibility" name="feasibility" value="${game.feasibility}"/>		
								</div>
								<div class="clearfloat"></div>
							</div>
							

							<div class="forminput">
								<button type="submit" id="submitbtn">
									<spring:message code='Label.common.save' />
								</button>
								<button type="reset" id="reset">
									<spring:message code='Label.common.reset' />
								</button>
								
								<button id="cancel" onclick="window.location.href='<%=basePath%>admin/game/list'">
									<spring:message code='Label.common.cancel'/>
								</button>
								
							</div>

						</fieldset>
					</form>

				</div>
			</div>

			<!-- end .content -->
		</div>
		<div class="clearfloat" />
		<%@include file="../../footer.jsp"%>
		<!-- end .container -->
	</div>
</body>
</html>